<!doctype html>


<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>eventtarget.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
  </script>

  <script src="static/js/doc.js">
  </script>

  <meta charset="utf8">
</head>

<body onload="prettyPrint()">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>





<div class="colmask rightmenu">
<div class="colleft">
    <div class="col1">
      <!-- Column 1 start -->

<div id="title">
       <span class="fn">eventtarget.js</span>
</div>

<div class="g-section g-tpl-75-25">
  <div class="g-unit g-first" id="description">
    Implementation of EventTarget as defined by W3C DOM 2/3.
  </div>
  

        <div class="g-unit" id="useful-links">
          <div class="title">Useful links</div>
          <ol>
            <li><a href="closure_goog_events_eventtarget.js.source.html"><span class='source-code-link'>Source Code</span></a></li>
          </ol>
        </div>
</div>

<h2 class="g-first">File Location</h2>
  <div class="g-section g-tpl-20-80">
    <div class="g-unit g-first">
      <div class="g-c-cell code-label">events/eventtarget.js</div>
    </div>
  </div>
<hr/>


  <h2>Classes</h2>
 <div class="fn-constructor">
        <a href="class_goog_events_EventTarget.html">
          goog.events.EventTarget</a><br/>
        <div class="class-details">This implements the EventTarget interface as defined by W3C DOM 2/3. The
main difference from the spec is that the this does not know about event
propagation and therefore the flag whether to use bubbling or capturing is
not used.

Another difference is that event objects do not really have to implement
the Event interface. An object is treated as an event object if it has a
type property.

It also allows you to pass a string instead of an event object and in that
case an event like object is created with the type set to the string value.

Unless propagation is stopped, events dispatched by an EventTarget bubble
to its parent event target, returned by <code>getParentEventTarget</code>.
To set the parent event target, call <code>setParentEventTarget</code> or
override <code>getParentEventTarget</code> in a subclass.  Subclasses that
don&#39;t support changing the parent event target should override the setter
to throw an error.

Example usage:
<pre class="lang-js">
var et = new goog.events.EventTarget;
function f(e) {
alert(&quot;Type: &quot; + e.type + &quot;\nTarget: &quot; + e.target);
}
et.addEventListener(&quot;foo&quot;, f);
...
et.dispatchEvent({type: &quot;foo&quot;}); // will call f
// or et.dispatchEvent(&quot;foo&quot;);
...
et.removeEventListener(&quot;foo&quot;, f);

// You can also use the EventHandler interface:
var eh = {
handleEvent: function(e) {
...
}
};
et.addEventListener(&quot;bar&quot;, eh);
</pre></div>
 </div>
      








      <!-- Column 1 end -->
    </div>

        <div class="col2">
          <!-- Column 2 start -->
          <div class="col2-c">
            <h2 id="ref-head">Directory events</h2>
            <div id="localView"></div>
          </div>

          <div class="col2-c">
            <h2 id="ref-head">File Reference</h2>
            <div id="sideFileIndex" rootPath="closure/goog" current="events/eventtarget.js"></div>
          </div>
          <!-- Column 2 end -->
        </div>
</div>
</div>

</body>
</html>
